<?php
	require_once('config.php');
	require_once('db.php');
	$link = connectdb($servername,$dbname,$dbusername,$dbpassword);
 	if(!$link)
 	{
 		die("Could not connect to MySQL");
 	}
 	$query="select * from protocols";
 	$rt=mysql_query($query);          // query executed
 	if (!$rt)
 	{
 		echo mysql_error();
 		return;
 	}
?>
<div align="center"><h1>Protocol Management</h1></div>
<table width="40%" style="margin-left: 30%" border="1" cellspacing="1" cellpadding="0">
<tr>
<td>
	<table width="400" border="0" cellspacing="0" cellpadding="3">
		<tr>
			<td align="center"><strong>ID</strong></td>
			<td align="center"><strong>Name</strong></td>
			<td align="center"><strong>Port</strong></td>
			<td align="center"><strong>Update</strong></td>
			<td align="center"><strong>Delete</strong></td>			
		</tr>

		<?php
			while($rows=mysql_fetch_array($rt)){
		?>
		<tr>
			<?php
				$id=$rows['id'];
			 ?>
			<td align="center"><?php echo $id; ?></td>
			<td align="center"><?php echo $rows['name']; ?></td>
			<td align="center"><?php echo $rows['port']; ?></td>			
			<td align="center"><a href="updateprotocol.php?id=<?php echo $id; ?>">update</a></td>
			<td align="center"><a href="deletePro.php?id=<?php echo $id; ?>">delete</a></td>
		</tr>
		<?php
			}
		?>
		<tr>
			<td align="right" colspan="5"><a href="addprotocol.php">Add new</a></td>
		</tr>		
	</table>
</td>
</tr>
</table>
<div align="center"><?php if(isset($_GET['message'])) echo $_GET['message'];?></div><br />
<div align="center"><a href="index.php">Back to Main Menu</a></div>
<?php
	close($link);
?>